package com.gking.centerSystem.mapper;


import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gking.centerSystem.entity.SystemInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface SystemInfoMapper extends BaseMapper<SystemInfo> {


    /**
     * 获取系统信息分页
     *
     * @param page       分页信息
     * @param systemCode 系统编码
     * @return
     */
    @Select("<script>" +
            "SELECT DISTINCT systemInfo.* ,rootSystem.createTime as createTime2 " +
            "FROM sy_system_info systemInfo " +
            "JOIN sy_root_system rootSystem ON rootSystem.systemCode = systemInfo.systemCode " +
            "WHERE rootSystem.enable = 0 AND rootSystem.isDelete = 0 " +
            "AND systemInfo.isDelete = 0 " +
            "<if test='systemCode != null and systemCode.trim() neq \"\"'> AND systemInfo.systemCode = #{systemCode} </if> " +
            "ORDER BY rootSystem.createTime DESC, systemInfo.systemCode ASC " +
            "</script>")
    IPage<SystemInfo> getSystemInfoPage(Page<SystemInfo> page,
                                        @Param("systemCode") String systemCode);

}
